﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace EntityFramework.Helper.Persister
{
    /// <summary>
    /// Interface that defines the operations of a Entity Object persister. 
    /// </summary>
    /// <typeparam name="E">The entity object type that will be persisted.</typeparam>
    public interface IPersister<E> where E : System.Data.Objects.DataClasses.EntityObject
    {
        #region Fields

        /// <summary>
        /// Defines the context of the Persister.
        /// </summary>
        System.Data.Objects.ObjectContext Context
        {
            get;
            set;
        }

        HashSet<E> EntityObjects
        {
            get;
        }

        #endregion

        #region Methods

        /// <summary>
        /// Adds the entity object to the persister context.
        /// </summary>
        /// <param name="entityObject">The entity object to be added.</param>
        /// <returns>True if it was correctly added, false if not.</returns>
        bool AddToPersister(E entityObject);

        /// <summary>
        /// Saves the EntityObject.
        /// </summary>
        void SavePersisterContext();

        /// <summary>
        /// Saves a specific entity object.
        /// </summary>
        /// <param name="entityObject">The entity object to be saved.</param>
        void Save(E entityObject);

        /// <summary>
        /// Deletes the EntityObject from the informed context.
        /// </summary>
        /// <param name="context">The EntityObject's context.</param>
        void DeletePersisterContext();

        /// <summary>
        /// Deletes a specific entity object.
        /// </summary>
        /// <param name="entityObject">The entity object to be deleted.</param>
        void Delete(E entityObject);

        /// <summary>
        /// Returns an EntityObject.
        /// </summary>
        /// <returns>EntityObject</returns>
        E GetEntityObject();

        #endregion

    }
}
